package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmReimburseEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmReimburseMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 报销Service接口
 * @author: yhli
 * @date 2020-06-28 18:30
 */
@Service
public class bpmCrmReimburseService extends ServiceImpl<bpmCrmReimburseMapper,bpmCrmReimburseEntity> {

	@Resource
	private bpmCrmReimburseMapper bpmCrmReimburseMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmReimburseEntity> queryWrapper = new QueryWrapper<bpmCrmReimburseEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String reimburseTime = (String) params.get("reimburseTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseTime), "reimburse_time", reimburseTime);
          String reimburseAmount = (String) params.get("reimburseAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseAmount), "reimburse_amount", reimburseAmount);
          String reimburseAttaFilepath = (String) params.get("reimburseAttaFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseAttaFilepath), "reimburse_atta_filepath", reimburseAttaFilepath);
          String cashierAmount = (String) params.get("cashierAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierAmount), "cashier_amount", cashierAmount);
          String cashierApproval = (String) params.get("cashierApproval");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierApproval), "cashier_approval", cashierApproval);
             String financeProportion = (String) params.get("financeProportion");
         queryWrapper.eq(ToolUtil.isNotEmpty(financeProportion), "finance_proportion", financeProportion);
          String financeAmount = (String) params.get("financeAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(financeAmount), "finance_amount", financeAmount);
          String financeApproval = (String) params.get("financeApproval");
         queryWrapper.eq(ToolUtil.isNotEmpty(financeApproval), "finance_approval", financeApproval);
             String accountingApproval = (String) params.get("accountingApproval");
         queryWrapper.eq(ToolUtil.isNotEmpty(accountingApproval), "accounting_approval", accountingApproval);
     		Page<bpmCrmReimburseEntity> page = bpmCrmReimburseMapper.selectPage(new Query<bpmCrmReimburseEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmReimburseEntity bpmCrmReimburseEntity) {
		Page<bpmCrmReimburseEntity> page = bpmCrmReimburseMapper.findPage(new Query<bpmCrmReimburseEntity>(params).getPage(), bpmCrmReimburseEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmReimburseByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmReimburseById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmReimburse(bpmCrmReimburseEntity bpmCrmReimburse){
        bpmCrmReimburse.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmReimburse);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmReimburseById(bpmCrmReimburseEntity bpmCrmReimburse) {
		return updateById(bpmCrmReimburse);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmReimburseEntity getbpmCrmReimburseById(String id){
		return getById(id);
	}
}
